<?php
include("../../inc/global.inc");
include("islogin.php");

if(isset($_POST['submit']) && $_POST['submit'])
{
	if($_POST['id'])
	{
		$array = $_POST['info'];
		$array['updatetime'] = time();
		$true = $db->update('sd_yinhang', $array,"id=".$_POST['id']." and username='".$per_row['m_user']."'");
		echo "<script>alert('修改成功');location='/member/tuoguan/yh.php?fukuan=2';</script>";exit;
	}
	else
	{
			$array = $_POST['info'];
			$array['inputtime']=time();
			$array['updatetime']=time();
			$array['ip']=ip();
			$array['userid']=$per_row['id'];
			$array['username']=$per_row['m_user'];
		$true = $db->insert('sd_yinhang', $array);
		if($true)
		{
			echo "<script>alert('添加银行信息成功');location='/member/tuoguan/yh.php?fukuan=2';</script>";exit;
		}
		else
		{
			echo "<script>alert('失败，未知原因。请联系管理员');location='".HTTP_REFERER."';</script>";exit;
		}
	}
	
}
$head['title']='我的银行信息';
$rows = $db->get_one("select * from sd_yinhang where userid=".$per_row['id']);	
include("top.php");
?>
<div class="con">
		   <div class="top5"><span>您当前位置：<a href="/help/">会员助手</a> &gt;&gt; 我的银行信息</span></div>
		   <?php include("left.php");?>
		   <div class="right">
		      <div class="y_5"></div>
		       <div class="con-tt"><span>收款银行账户</span></div>
			   <div class="con-t1"><span>你现有的银行帐户</span></div>
			   <div class="con-t2"><form action="" method="post" onsubmit="return check();">
               <input type="hidden" name="id" value="<?php echo $rows['id'];?>" />
<table width="100%" border="0" cellpadding="0" cellspacing="0" >
	                 <tr>
		                <td width="20%" height="32" align="center" bgcolor="#EFF6FF"> 收款公司或个人名称：</td>
	                    <td colspan="2" bgcolor="#f9f9f9"><input name="info[mc]" id="mc" type="text" class="txt1" value="<?php echo $rows['mc'];?>"/></td>                    
					 </tr>
	                 <tr>
		                <td  height="32" align="center" bgcolor="#EFF6FF">开户银行名称：</td>
		                <td colspan="2" bgcolor="#f9f9f9"><input name="info[khmc]" id="khmc" type="text" class="txt1" value="<?php echo $rows['khmc'];?>"/>  </td>
	                </tr>
                    <tr>
		                <td  height="32" align="center" bgcolor="#EFF6FF">开户银行帐号：</td>
		                <td colspan="2" bgcolor="#f9f9f9"><input name="info[khzh]" id="khzh" type="text" class="txt1" value="<?php echo $rows['khzh'];?>"/>  </td>
	                </tr>
                    
	                 <tr>
		                <td height="32" bgcolor="#EFF6FF" align="center">开户银行地址：</td>
		                <td width="79%" bgcolor="#f9f9f9"><input name="info[khdz]" id="khdz" type="text" class="txt1" value="<?php echo $rows['khdz'];?>"/>
						</td>
                    </tr>
	                <tr>
		              <td height="32" colspan="3" bgcolor="#EFF6FF" align="left"> &nbsp; 您的支付宝账户：</td>
	               </tr>  
					 <tr>
		                <td height="32" bgcolor="#EFF6FF" align="center">您的收款人：</td>
		                <td colspan="2" bgcolor="#f9f9f9"><input name="info[zubmc]" id="zubmc" type="text" class="txt1" value="<?php echo $rows['zubmc'];?>"/>
	                     </td>
	                </tr>
	                 <tr>
		                <td height="32" bgcolor="#EFF6FF" align="center">您的支付宝账号：</td>
		                <td colspan="2" bgcolor="#f9f9f9"><input name="info[email]" id="email" type="text" class="txt1" value="<?php echo $rows['email'];?>"/>
	                    </td>
	                </tr>
	               
	                 <tr>
		                <td height="35" bgcolor="#EFF6FF">&nbsp;</td>
		                <td colspan="2" bgcolor="#f9f9f9">&nbsp;
						<?php if($rows['id']){?><input  name="submit" type="submit" value="修改" class="btn1"/><?php }else{?> <input  name="submit" type="submit" value=" 提交" class="btn"/><?php }?></td>
	                </tr>
					 <tr>
		                <td height="35"  align="center" bgcolor="#EFF6FF">&nbsp;</td>
		                <td colspan="2" bgcolor="#f9f9f9"><div class="txt STYLE1">请注意，请您仔细填写您的银行资料，确保您的资料是正确的，提交后本次交易不可以再修改。
</div></td>
	                </tr>
                 </table></form>
               </div>
		 </div>
		 <div class="cl"></div>
</div> 
<?php include("foot.php");?>
<script>
	function check()
	{
		if($('#mc').val()=='')
		{
			alert('请输入收款公司或个人名称');
			$('#mc').focus();
			return false;
		}
		if($('#khmc').val()=='')
		{
			alert('请输入开户银行名称');
			$('#khmc').focus();
			return false;
		}
		if($('#khdz').val()=='')
		{
			alert('请输入开户银行地址');
			$('#khdz').focus();
			return false;
		}
	}
</script>
